﻿<ResourceDictionary
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  xmlns:con="clr-namespace:System.Controls">
  
  <ResourceDictionary.MergedDictionaries>
    <ResourceDictionary Source="Graphics/Editor.xaml"/>
  </ResourceDictionary.MergedDictionaries>

  <ControlTemplate x:Key="GearTemplate" TargetType="{x:Type con:Gear}">
    <ControlTemplate.Resources>
      <Storyboard x:Key="animation_rotate" RepeatBehavior="Forever">
        <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="ellipse" Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[2].(RotateTransform.Angle)">
          <SplineDoubleKeyFrame KeyTime="00:00:02" Value="360"/>
        </DoubleAnimationUsingKeyFrames>
      </Storyboard>
    </ControlTemplate.Resources>
    
    <Ellipse 
      RenderTransformOrigin="0.5,0.5"
      Fill="{StaticResource StdNew.icon}">
      <Ellipse.RenderTransform>
        <TransformGroup>
          <ScaleTransform ScaleX="1" ScaleY="1"/>
          <SkewTransform AngleX="0" AngleY="0"/>
          <RotateTransform Angle="0"/>
          <TranslateTransform X="0" Y="0"/>
        </TransformGroup>
      </Ellipse.RenderTransform>
    </Ellipse>
    <ControlTemplate.Triggers>
      <Trigger Property="Rotate" Value="True">

        <Trigger.EnterActions>
          <BeginStoryboard x:Name="animation_rotate_BeginStoryboard" Storyboard="{StaticResource animation_rotate}"/>
        </Trigger.EnterActions>

        <Trigger.ExitActions>
          <StopStoryboard BeginStoryboardName="animation_rotate_BeginStoryboard"/>
        </Trigger.ExitActions>
        
      </Trigger>

    </ControlTemplate.Triggers>

  </ControlTemplate>

  <Style TargetType="{x:Type con:Gear}">
    <Setter Property="Template" Value="{StaticResource GearTemplate}"/>
  </Style>

</ResourceDictionary>